package com.cn.intelligence.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.intelligence.pojo.TaotaoResult;
import com.cn.intelligence.pojo.TbItemCat;
import com.cn.intelligence.service.ItemCatService;

/**
 * Created by Administrator on 2017/4/18.
 */
@Controller
@RequestMapping("/item/cat/")
public class ItemCatController {
    @Autowired
    private ItemCatService itemCatService;
    
    /**
     * 查询书树节点信息
     * @param parentId
     * @return
     */
    @RequestMapping("list")
    @ResponseBody
    public List<Map<String,Object>> getCatList(@RequestParam(value = "id",defaultValue = "0") Long parentId){
    	List<Map<String,Object>> euTreeNodeList = itemCatService.getItemCatList(parentId);
        return euTreeNodeList;
    }
    
    /**
     * 查询书树节点信息
     * @param parentId
     * @return
     */
    @RequestMapping("catname")
    @ResponseBody
    public TaotaoResult getCatname(String catid){
    	TaotaoResult tbItemCat = itemCatService.getItemCatDesc(catid);
        return tbItemCat;
    }
    
    /**
     * 添加
     * @param parentId
     * @return
     */
    @RequestMapping("add")
    @ResponseBody
    public TaotaoResult addCat(TbItemCat tbItemCat){    	
    	TaotaoResult resutl = itemCatService.addItemCat(tbItemCat);
    	
        return resutl;
    }
    /**
     * 修改
     * @param parentId
     * @return
     */
    @RequestMapping("update")
    @ResponseBody
    public TaotaoResult updateCat(TbItemCat tbItemCat){    	
    	TaotaoResult resutl = itemCatService.updateItemCat(tbItemCat);
    	
        return resutl;
    }
    /**
     * 修改
     * @param parentId
     * @return
     */
    @RequestMapping("delete")
    @ResponseBody
    public TaotaoResult deleteCat(Long id){    	
    	TaotaoResult resutl = itemCatService.deleteItemCat(id);
    	
        return resutl;
    }
}
